package com.zmn.oms.dubbo.impl.zmn.channel.order;

import org.apache.dubbo.config.annotation.Service;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.common.constant.OrderConsts;
import com.zmn.oms.dubbo.interfaces.zmn.channel.order.ChannelOrderListRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.vo.work.OperatePermissionVO;
import com.zmn.oms.zmn.business.interfaces.work.ZsOrderWorkOperatePermissionBService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.constraints.NotNull;

/**
 * 渠道订单查询相关
 * @author: LuJia
 * @version: v1.0
 * @since: 2020/05/20 14:38
 **/
@Slf4j
@Service(loadbalance = "roundrobin", timeout = 3000, retries = -1, version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class ChannelOrderListRemoteServiceImpl implements ChannelOrderListRemoteService {

    @Autowired
    ZsOrderWorkOperatePermissionBService orderWorkOperatePermissionBService;

    @Override
    public ResponseDTO checkUpdateChannelPrepayAmount(@NotNull Long orderId, @NotNull Long workId) {
        OperatePermissionVO operatePermission = orderWorkOperatePermissionBService.getOperatePermission(orderId, workId, OrderConsts.ORDER_OP_TYPE_UPDATE_CHANNEL_PREPAY_AMOUNT);
        if (!operatePermission.getCanOperate()) {
            return ResponseDTO.fail(operatePermission.getMsg());
        }
        return ResponseDTO.success();
    }
}
